//
//  CFWithdrawVC.m
//  CFfuturestalent
//
//  Created by 子yu 刘 on 2018/5/1.
//  Copyright © 2018年 子yu 刘. All rights reserved.
//

#import "CFWithdrawVC.h"
#import "CFWithdrawBankCell.h"
#import "CFwithdrawRecordVC.h"
#import "CFPasswordView.h"

@interface CFWithdrawVC ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UIImageView *selImage;
@property (nonatomic ,assign) BOOL isPull;
@property (nonatomic ,assign) NSInteger selectedIndex;

@end

@implementation CFWithdrawVC

- (void)viewDidLoad {
    [super viewDidLoad];
    _selectedIndex = -1;
    self.tableViewHeight.constant = 0;
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem barBtnItemWithTitle:@"提现记录" target:self action:@selector(topUpRecords)];
    [self.tfMoney setValue:[UIColor colorWithHexString:@"687278"]
                forKeyPath:@"_placeholderLabel.textColor"];
}

- (void)topUpRecords{
    CFwithdrawRecordVC * recordVC = (CFwithdrawRecordVC *)[CFUtility getVC:@"CFwithdrawRecordVC" Storyboard:MINE];
    [self.navigationController pushViewController:recordVC animated:YES];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CFWithdrawBankCell * cell = [tableView dequeueReusableCellWithIdentifier:@"CFWithdrawBankCell"];
    if (_selectedIndex == indexPath.row) {
        cell.selImg.image = DEF_IMAGENAME(@"选中");
    }else{
          cell.selImg.image = DEF_IMAGENAME(@"未选中");
    }
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    _selectedIndex = indexPath.row;
    [self.tableView reloadData];
}
- (IBAction)chooseBank:(id)sender {
    _isPull = !_isPull;
    if (self->_isPull) {
        self.line.hidden = NO;
        self.selImage.image = [UIImage imageNamed:@"上"];
        self.tableViewHeight.constant = 180;
    }else{
        self.line.hidden = YES;
        
        self.selImage.image = [UIImage imageNamed:@"下"];
        self.tableViewHeight.constant = 0;
    }
    [UIView animateWithDuration:0.3 animations:^{
        [self.view layoutIfNeeded];
    }];
}
- (IBAction)withdrawAll:(id)sender {
    self.tfMoney.text = @"1000.01";
}

- (IBAction)next:(id)sender {
    if ([self.tfMoney.text floatValue]<=0) {
        [AlertUtil alertMessage:@"请输入提现金额"];
        return;
    }
    if (_selectedIndex<0) {
        [AlertUtil alertMessage:@"请先选择银行卡"];
        return;
    }
    [CFPasswordView showWithBtnClicked:^{
        
    }];
    
}


@end
